tree grammar CalculatorWalker;

options {
  tokenVocab = CalculatorParser;
  ASTLabelType = CommonTree;
}

@header{
package org.concepts.java.antlr.calculator;
}

expr returns [int result = 0]
  :^(PLS first=expr second=expr)
  {
    result = first + second; 
  }
  |
  ^(MIN first=expr second=expr)
  {
    result = first - second; 
  }
  |
  ^(MUL first=expr second=expr)
  {
    result = first  * second; 
  }
  |
  ^(DIV first=expr second=expr)
  {
    result = first / second; 
  }
  |
  INT
  {
    result = Integer.parseInt($INT.text);
  }
  ;
